<?php
class FeedbackAction extends GlobalAction{
	public function index(){
	$this->feedback_list();
	}
	public function feedback_list(){
    	$feedback = M('feedback');
    	import("@.ORG.Page"); //导入分页类 
        $count = $feedback->count();    //计算总数 
        $p = new Page ( $count, 20 ); 
    	$feedback = $feedback->limit($p->firstRow.','.$p->listRows)->order('feedback_id asc')->findall();
    	$page = $p->show (); 
        $this->assign( "page", $page ); 
    	$this->assign('feedback',$feedback);
    	$this->GlobalName();
		$this->display('list');
    }
    /*
	public function feedback_search(){
        $search['title'] = array('like','%'.$_POST['search'].'%');
        $search['name'] = array('like','%'.$_POST['search'].'%');
        $search['qq'] = array('like','%'.$_POST['search'].'%');
        $search['mail'] = array('like','%'.$_POST['search'].'%');
        $search['contents'] = array('like','%'.$_POST['search'].'%');
        $search['_logic'] = 'or';
    	$feedback = M('feedback');
    	import("@.ORG.Page"); //导入分页类 
        $count = $feedback->where($search)->count();    //计算总数 
        $p = new Page ( $count, 20 ); 
    	$feedback = $feedback->where($search)->limit($p->firstRow.','.$p->listRows)->order('feedback_id asc')->findall();
    	$page = $p->show (); 
        $this->assign( "page", $page ); 
    	$this->assign('feedback',$feedback);
    	$this->GlobalName();
		$this->display('list');
    }
    */
    public function edit(){
    	$pid = $_GET['pid'];
    	$feedback = M('feedback');
    	$feedback_l = $feedback->where('feedback_id = '.$pid)->findall();
    	$this->assign('feedback',$feedback_l);
    	$this->GlobalName();
		$this->display();
    }
    public function feedback_edit_get(){
    	$feedback = M('feedback');
    	if ($_POST['reply'] != "") {
	    	$feedback->find($_POST['feedback_id']);
	    	$feedback->new = '0';
	    	$feedback->save();
    	}
    	$feedback->create();
    	if ($feedback->save()) {
    		$this->get_alert('修改成功');
    	};
    }
    
    public function feedback_delete(){
    	$feedback = M('feedback');
    	$del = $_POST['del'];
    	$delete = $del[0];
    	for ($i=1;$i < count($del);$i++){
    		$delete = $delete.','.$del[$i];
    	}
    	if ($feedback->delete($delete)) {
    		$this->get_alert('删除成功');
    	};
    }
    
    public function ajax_show(){
    	$this->ajax_get('feedback','show_m');
    }
    public function left(){//默认左列表
    	$left = array(
    		array('sort'=>'feedback','name'=>'新闻管理','value'=>'feedback_list')
    	);
     	$this->assign('user',$_SESSION['User']);
    	$this->assign('sort',$sort);
    	$this->assign('left',$left);
    	$this->display('Index:left');
    }
}
?>